home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Database
/
Evaluator
/
ScrollViewExtras.m
< prev
next >
Wrap
Text File
|
1993-07-21
|
1KB
|
74 lines
/* ScrollViewExtras.m:
* You may freely copy, distribute, and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to its
* fitness for any particular use.
*
* A generic scrollview driver object to display/print text
* Written by Jack Greenfield
*
*/
#import <objc/objc-runtime.h>
#import "ScrollViewExtras.h"
@implementation ScrollView(ScrollViewExtras)
- sprintf:(const char *)format, ...
{
int length;
static char buffer[65536];
va_list arguments;
if ([window isVisible])
{
va_start(arguments, format);
vsprintf(buffer, format, arguments);
va_end(arguments);
length = [[self docView] textLength];
[[self docView] setSel:length :length];
[[self docView] replaceSel:buffer];
[[self docView] scrollSelToVisible];
}
return self;
}
- clear:sender
{
int length;
if ([window isVisible])
{
length = [[self docView] textLength];
[[self docView] setSel:0 :length];
[[self docView] replaceSel:""];
[[self docView] scrollSelToVisible];
}
return self;
}
- print:sender
{
if ([window isVisible])
[[self docView] printPSCode:sender];
return self;
}
- printFrom:sender
{
return [self sprintf:"%s\n", [sender stringValue]];
}
/* Window Delegate method -- constrain window resizing */
- windowWillResize:sender toSize:(NXSize *)frameSize
{
if ( frameSize->height < 230 ) frameSize->height= 230;
return self;
}
@end